/*
 * Create Date 2006-5-19
 */
package com.jmcgg.freesky.common.db;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * Title: FreeSky Common Java Library <br>
 * Description: FreeSky Common Java Library <br>
 * Copyright: Copyright (c) 2005~2009 www.afss.cn <br>
 * Company: Amei's FreeSky Studio <br>
 *
 * @author <b>Jacky Chou</b> (AFSS [Amei's FreeSky Studio])
 * @version 1.2.0, 2008-02-23, Upgrade freesky.jar to 1.2.0 with Struts 2
 * <br>1.0.0, 2006-05-30, Initial Version
 */
/**
 * ��������ʵ�֡� ��ɷ������£� 1. public void getConnection()
 * �����ӳ�ȡ����ݿ����� 2. public Connection getDBConnection()
 * ����һ����ݿ����� 3. public ResultSet executeQuery(String sqlStr)
 * ��ݴ���Ĳ���sqlStr��ѯ���õ������ز�ѯ���ResultSet 4. public
 * PreparedStatement prepareStatement(String sqlStr)
 * Ϊ�ⲿ�����ṩԤ����䣬���Ч�� 5. public boolean executeUpdate(String
 * sqlStr) ��ݴ������sqlStr������ݿ⣬������û�н���commit 6. public void
 * beginTran(boolean supportTran)
 * ��supportTranΪtrueʱ��֧�������?����ʼ������� 7. public void
 * commitTran() ����ύ�������ر����ڴ�������ʱһ��Ҫ���� 8. public boolean
 * rollBackTran() �����²��ɹ�ʱ��ROLLBACK 9. public void close() �ر����� 10.
 * public void closeResultSet(ResultSet rs) �ر� ��ѯ��� 11. public void
 * closeStatement(Statement st) �ر� Statement
 * �����쳣���?�����Ӻ͹ر�û���쳣���?���඼�׳��쳣
 */
public interface IDBConn {
	public void getConnection();

	/**
	 * ����һ������conn
	 * 
	 * @return conn is a Connection to database
	 */
	public abstract Connection getDBConnection();

	/**
	 * ��ݲ�ѯ���sqlstr��ѯ��ݿ�
	 * 
	 * @param sqlStr
	 * @return ResultSet
	 */
	public abstract ResultSet executeQuery(String sqlStr) throws SQLException;

	/**
	 * ����prepareStatement��Ϊ���������������������sql����еĲ�����������
	 * 
	 * @param sqlStr
	 * @return pstmt PreparedStatement
	 * @throws SQLException
	 */
	public abstract PreparedStatement prepareStatement(String sqlStr)
			throws SQLException;

	/**
	 * ������sqlStr������ݿ�
	 * 
	 * @param sqlStr
	 *            ������ݿ��SQL���
	 * @return ������ݿ�Ӱ�������
	 * @throws SQLException
	 *             ����ʧ�ܵ��쳣
	 */
	public abstract int executeUpdate(String sqlStr) throws SQLException;

	/**
	 * ��־��ʼ����
	 * 
	 * @param supportTran
	 *            If supportTran is true, it is a Transaction. And
	 *            setAutoCommit(false). If supportTran is false, it is NOT a
	 *            Transaction. And setAutoCommit(true).
	 * @throws SQLException
	 */
	public abstract void beginTran(boolean supportTran) throws SQLException;

	/**
	 * ����ύ����
	 * 
	 * @throws SQLException
	 */
	public abstract void commitTran() throws SQLException;

	/**
	 * rollBack
	 * 
	 * @return
	 * @throws SQLException
	 */
	public abstract boolean rollBackTran() throws SQLException;

	/**
	 * �ر�����
	 */
	public abstract void close();

	/**
	 * close ResultSet
	 * 
	 * @param rs
	 */
	public abstract void closeResultSet(ResultSet rs);

	/**
	 * close Statement
	 * 
	 * @param st
	 */
	public abstract void closeStatement();

	/**
	 * �õ�һ������ܹ���¼��
	 * 
	 * @param sql
	 *            String
	 * @return int
	 */
	public abstract int getTotal(String sql);
}
